// 引入axios
import axios from "../../index";

// 获取头部导航条数据
function getHeaders() {
    return axios({
        method: 'get',
        url: '/api/admin/store/product/tabs/headers'
    })
}

// 获取分页列表
function product_list(page, limit, type, keywords, cateId) {
    return axios({
        method: 'get',
        url: '/api/admin/store/product/list',
        params: {
            page,
            limit,
            cateId,
            keywords,
            type,
        }
    })
}

// 商品下架
function offShell(id) {
    return axios({
        method: "get",
        url: `/api/admin/store/product/offShell/${id}`
    })
}

// 商品上架
function putOnShell(id) {
    return axios({
        method: "get",
        url: `/api/admin/store/product/putOnShell/${id}`
    })
}

// 商品详情
function productInfo(id) {
    return axios({
        method: "get",
        url: `/api/admin/store/product/info/${id}`
    })
}

// 图片列表

function attachmentList(pid, page, limit) {
    return axios({
        method: "get",
        url: `/api/admin/system/attachment/list`,
        params: {
            pid, page, limit,
            attType: 'jpg,jpeg,gif,png,bmp,PNG,JPG'
        }
    })
}
// 图片删除
function deleteImg(str) {
    return axios({
        method: "get",
        url: `/api/admin/system/attachment/delete/${str}`,

    })
}

// 图片移动
function move(attrId, pid) {
    return axios({
        method: "post",
        url: `/api/admin/system/attachment/move`,
        data: {
            pid, attrId,
        }
    })
}

// 图片本地上传
function uploadImg(pid, multipart) {
    return axios({
        method: 'post',
        url: `/api/admin/upload/image?model=content&pid=${pid}`,
        data: multipart,
        'Content-Type': "multipart/form-data; boundary=----WebKitFormBoundaryBIoqa700iOeMZ2Ut"
    })
}
// 物流模板列表

function shippingList(keywords) {
    return axios({
        method: "get",
        url: `/api/admin/express/shipping/templates/list`,
        params: {
            limit: 999,
            page: 1,
            keywords
        }
    })
}

// 获取城市列表
function Citylist() {
    return axios({
        method: 'get',
        url: '/api/admin/system/city/list/tree'
    })
}
// 新增物流模板
function addModule(data) {
    return axios({
        method: "post",
        url: `/api/admin/express/shipping/templates/save`,
        data,
    })
}
// 导出
export { getHeaders, product_list, offShell, putOnShell, productInfo, attachmentList, deleteImg, move, uploadImg, shippingList, Citylist, addModule }